<template>
  <div class="app-container">
    <!-- <strong>讲师列表</strong> -->
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="adminSuperQuery.name" placeholder="教师名"/>
      </el-form-item>

      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>

    <!-- 表格 -->
    <el-table
      :data="list"
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        width="70"
        align="center"
      >
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column label="审核员工号" prop="adminUsername" align="center"/>

      <el-table-column label="审核员姓名" prop="name" align="center"/>

      <el-table-column label="教师所属学院" prop="supCollege" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.supCollege === 1">商学院</span>
          <span v-if="scope.row.supCollege === 2">管理学院</span>
          <span v-if="scope.row.supCollege === 3">外语学院</span>
          <span v-if="scope.row.supCollege === 4">堪萨斯国际学院</span>
          <span v-if="scope.row.supCollege === 5">电信与智能制造学院</span>
          <span v-if="scope.row.supCollege === 6">计算机与软件工程学院</span>
          <span v-if="scope.row.supCollege === 7">艺术设计学院</span>
          <span v-if="scope.row.supCollege === 8">医学院</span>
          <span v-if="scope.row.supCollege === 9">文法学院(语委办)</span>
          <span v-if="scope.row.supCollege === 10">体育学院</span>
          <span v-if="scope.row.supCollege === 11">新闻与传播学院</span>
          <span v-if="scope.row.supCollege === 12">建筑工程学院</span>
          <span v-if="scope.row.supCollege === 13">音乐戏剧学院</span>
          <span v-if="scope.row.supCollege === 14">马克思主义学院</span>
          <span v-if="scope.row.supCollege === 15">国际教育学院</span>
          <span v-if="scope.row.supCollege === 16">教育学院</span>
          <span v-if="scope.row.supCollege === 17">继续教育学院</span>
          <span v-if="scope.row.supCollege === 18">国际语言中心</span>
        </template>
      </el-table-column>


      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <router-link :to="'/adminSuper/updateSuper/'+scope.row.id">
            <el-button type="text" size="4px" icon="el-icon-edit" class="edit-button"><strong>修改</strong></el-button>
          </router-link>
          <el-button type="text" size="4px" icon="el-icon-delete" class="delete-button" @click="deleteTeacherById(scope.row.adminUsername)"><strong>删除</strong>
          </el-button>
        </template>
      </el-table-column>

    </el-table>

    <!-- 分页 -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />


  </div>
</template>

<script>
// import teacher from '@/api/adm/teacherAdmin'
import * as teacher from '@/api/adm/teacherAdmin'
import { disable, disableTeacher } from '@/api/adm/teacherAdmin'

    export default {
      data() {
        return {
          list: null, // 查询之后接口返回集合
          page: 1, // 当前页
          limit: 10, // 每页记录数
          total: 0, // 总记录数
          adminSuperQuery: {} // 条件封装对象
        }
      },
      created() {
        this.getList()
      },
      methods: {
        // 条件查询教师信息
        getList(page = 1) {
          this.page = page
          teacher.findAllSuper(this.page, this.limit, this.adminSuperQuery)
            .then(response => {
              // 请求成功
              // response接口返回的数据
              // console.log(response)
              this.list = response.data.rows
              this.total = response.data.total
              console.log(this.list)
              console.log(this.total)
            })
        },

        //清空要查询的内容
        resetData() {
          this.adminSuperQuery = {}
          this.getList()
        },

        //删除教师账号
        deleteTeacherById(jobId){
          teacher.deleteSuper(jobId).then(response => {
            //删除成功
              this.$message({
                message: '删除成功',
                type: 'success'
              });
              this.getList()
          })
        },

        //修改教师信息
        updateDataById(){
        },

        beforeRemove(file, fileList) {
          return this.$confirm(`确定移除 ${file.name}？`)
        },
        handleDelete(index, row) {
        }
      }
}
</script>
<style>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}

.edit-button {
  color: rgb(217, 149, 38); /* 紫色 */
}


.delete-button {
  color: rgb(65, 150, 215); /* 红色 */
}
</style>
